package com.zmx.doctor.adapter;

import android.app.Activity;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.wang.adapters.adapter.BaseAdapterRvList;
import com.wang.adapters.base.BaseViewHolder;
import com.zmx.doctor.R;
import com.zmx.doctor.pojo.Meeting;
import com.zmx.doctor.pojo.SearchDoctor;

import butterknife.BindView;
import butterknife.ButterKnife;
import de.hdodenhof.circleimageview.CircleImageView;

/**
 * 程序猿：胖胖祥
 * 时 间：2020/8/8  16:29
 * 功 能：
 */
public class DotorAdapter extends BaseAdapterRvList<DotorAdapter.ViewHolder, SearchDoctor> {

    private Handler handler;
    private Integer logo;

    public DotorAdapter(Activity activity,Handler handler,Integer logo) {
        super(activity);
        this.handler = handler;
        this.logo = logo;
    }

    @Override
    protected void onBindVH(ViewHolder holder, int listPosition, SearchDoctor searchDoctor) {


        Glide.with(mActivity).load(searchDoctor.getAvatar()).into(holder.head);
        holder.name.setText(searchDoctor.getName());

        if (logo == 1){
            holder.add_meeting.setText("加入会议");
        }else if (logo == 2){

            holder.add_meeting.setText("邀请医生");

        }else{
            holder.add_meeting.setText("添加患者");
        }

        holder.add_meeting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                    Message message = handler.obtainMessage();
                    message.obj = searchDoctor.getUid();
                    message.what = 2;
                    handler.sendMessage(message);


            }
        });

    }

    @NonNull
    @Override
    protected ViewHolder onCreateVH(ViewGroup parent, LayoutInflater inflater) {

        DotorAdapter.ViewHolder holder = new DotorAdapter.ViewHolder(inflater.inflate(R.layout.dotor_adapter, parent, false));
        return holder;
    }

    static class ViewHolder extends BaseViewHolder {

        @BindView(R.id.name)
        TextView name;
        @BindView(R.id.add_meeting)
        Button add_meeting;
        @BindView(R.id.head)
        CircleImageView head;

        ViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }

    }


}
